import request from 'plugin/axios'

export function getDepartList(){
    return request({
        url:'v1/department/list',
        method:'get'
    })
}

export function addDepart(data:any):Promise<any>{
    return request({
        url:'v1/department/add',
        data,
        method:'post'
    })
}

export function editDepart(data:any):Promise<any>{
    return request({
        url:'v1/department/edit',
        data,
        method:'post'
    })
}

export function deleteDepart(data:any):Promise<any>{
    return request({
        url:'v1/department/delete',
        data,
        method:'post'
    })
}

export function getAccountList(params:any){
    return request({
        url:'v1/agent/list',
        params,
        method:'post'
    })
}

export function getAccountDetail(params:any){
    return request({
        url:`v1/agent/get`,
        params,
        method:'get'
    })
}

export function saveAccount(data: any){
    return request({
        url:'v1/agent/add',
        data,
        method:'post'
    })
}

export function editAccount(data: any){
    return request({
        url:'v1/agent/edit',
        data,
        method:'post'
    })
}

export function toggleAccount(data: any){
    return request({
        url:'v1/agent/status/toggle',
        data,
        method:'post'
    })
}

export function deleteAccount(data:{
    id:number | undefined
}){
    return request({
        url:'/user/delete',
        data,
        method:'post'
    })
}

export function resetAccountPassword(data : {
    id:number | undefined,
    password:string | undefined,
    password_confirm:string | undefined
}) {
    return request({
        url:'/user/resetPassword',
        data,
        method:'post'
    })
}

export function getRoleList(){
    return request({
        url:'v1/role/list',
        method:'get'
    })
}

export function addRole(data:any){
    return request({
        url:'v1/role/add',
        method:'post',
        data,
    })
}

export function saveRole(data: any){
    return request({
        url:'v1/role/edit',
        method:'post',
        data,
    })
}

export function toggleRole(data: any){
    return request({
        url:'v1/role/status/toggle',
        data,
        method:'post'
    })
}

export function deleteRole(data:{
    id:number | undefined
}){
    return request({
        url:'/role/delete',
        data,
        method:'post'
    })
}

export function setRole(data:{
    role_id: number | string,
    action_ids: number[]
}){
    return request({
        url:'v1/role/menu/action/set',
        data,
        method:'post'
    })
}

export function getMenuAndFnByRole(params: {
    role_id: number | string
}){
    return request({
        url:`v1/role/menu/action/get`,
        params,
        method:'get'
    })
}

export function saveRightsByRole(data:{
    role_id:number,
    resource_id_list:number[]
}){
    return request({
        url:'/role/set',
        method:'post',
        data,
    })
}

export function getDataRightsByRole(params: {
    role_id:number
}){
    return request({
        url:`/roleData/getDataByRoleId/${params.role_id}`,
        method:'get',
        params
    })
}

export function getUserListByRole(data : {
    role_id:number,
    current:number,
    size:number
}){
    return request({
        url:`/role/userList`,
        data,
        method:'post'
    })
}

export function getDataGroupList(data: {
    field_id:number,
    role_id:number
}){
    return request({
        url:'/roleData/getDataGroupList',
        data,
        method:'post'
    })
}

export function getDataGroupValueList(data: {
    field_id:number,
    role_id:number
}){
    return request({
        url:'/roleData/getDataGroupValueList',
        data,
        method: 'post'
    })
}

export function saveRoleData(data: {
    role_id:number,
    field_id:number,
    values:number[],
    group_ids:number[]
}){
    return request({
        url:'/roleData/save',
        data,
        method:'post'
    })
}

export function getAgentList(params:{
    name:string
}):Promise<any>{
    return request({
        url:'v1/agent/list',
        params,
        method:'get'
    })
}

export function getAgentDetail(params:{
    id:number
}):Promise<any>{
    return request({
        url:'v1/agent/get',
        params,
        method:'get'
    })
}

export function saveAgent(data:any):Promise<any>{
    return request({
        url:'v1/agent/add',
        data,
        method:'post'
    })
}

export function editAgent(data:any):Promise<any>{
    return request({
        url:'v1/agent/edit',
        data,
        method:'post'
    })
}


export function toggleAgent(data: any){
    return request({
        url:'v1/agent/status/toggle',
        data,
        method:'post'
    })
}

export function deleteAgent(data:{
    id:number | undefined
}){
    return request({
        url:'/user/delete',
        data,
        method:'post'
    })
}

export function getProviderList(params:{
    name:string
}):Promise<any>{
    return request({
        url:'v1/provider/list',
        params,
        method:'get'
    })
}

export function getProviderDetail(params:any){
    return request({
        url:`v1/provider/get`,
        params,
        method:'get'
    })
}

export function toggleProvider(data: any){
    return request({
        url:'v1/provider/status/toggle',
        data,
        method:'post'
    })
}


export function saveProvider(data: any){
    return request({
        url:'v1/provider/add',
        data,
        method:'post'
    })
}

export function editProvider(data: any){
    return request({
        url:'v1/provider/edit',
        data,
        method:'post'
    })
}

export function getCommissionConfig():Promise<any>{
    return request({
        url:'v1/common/rate/get',
        method:'get'
    })
}

export function setCommissionConfig(data:any):Promise<any>{
    return request({
        url:'v1/common/rate/set',
        method:'post',
        data
    })
}

export function getUserList(params:any):Promise<any>{
    return request({
        url:'v1/account/list',
        params,
        method:'get'
    })
}

export function getUserDetail(params:any):Promise<any>{
    return request({
        url:'v1/account/get',
        params,
        method:'get'
    })
}

export function saveUser(data: any){
    return request({
        url:'v1/account/add',
        data,
        method:'post'
    })
}

export function editUser(data: any){
    return request({
        url:'v1/account/edit',
        data,
        method:'post'
    })
}

export function toggleUser(data: any){
    return request({
        url:'v1/account/status/toggle',
        data,
        method:'post'
    })
}


export function getGiveList(params: any):Promise<any>{
    return request({
        url:'v1/give/list',
        params,
        method:'get'
    })
}

export function getGiveDetail(params: any):Promise<any>{
    return request({
        url:'v1/give/detail/get',
        params,
        method:'get'
    })
}

export function addGive(data:any):Promise<any>{
    return request({
        url:'v1/give/add',
        data,
        method:'post'
    })
}

export function editGive(data:any):Promise<any>{
    return request({
        url:'v1/give/edit',
        data,
        method:'post'
    })
}

export function setGive(data:any):Promise<any>{
    return request({
        url:'v1/give/seller/set',
        data,
        method:'post'
    })
}

export function toggleGive(data:any):Promise<any>{
    return request({
        url:'v1/give/status/toggle',
        data,
        method:'post'
    })
}